package me.aartikov.alligator.helpers;


import me.aartikov.alligator.animations.TransitionAnimation;
import me.aartikov.alligator.util.Log;
import ohos.aafwk.ability.fraction.FractionManager;

import java.util.List;


/**
 * Helper class for fragment switching.
 */
public class FractionSwitcher {
    private static final String TAG_PREFIX = "me.aartikov.alligator.FRAGMENT_SWITCHER_TAG_";
    private FractionManager mFragmentManager;

    public FractionSwitcher(FractionManager fragmentManager) {
        mFragmentManager = fragmentManager;
    }


    /**
     * 跳转fraction
     * @param fragment 需要跳转的fraction
     * @param animation 动画
     */
    public void switchTo(MiFraction fragment, TransitionAnimation animation) {
        Log.i("FragmentSwitcher.switchTo([fragment, animation]):24   "+mFragmentManager);
        FractionStack.getInstance(mFragmentManager).replace(fragment, animation);
    }

    /**
     * 还原fraction分组
     * @param fragments fraction分组
     */
    public void reduce(List<MiFraction> fragments) {
        FractionStack.getInstance(mFragmentManager).reduce(fragments);
    }

}
